#!/usr/bin/env python
# -*-coding:utf-8 -*-
import PIL
from PIL import Image
	
def crop_image(path):
	im = Image.open(path)
	w,h = im.size
	bb = im.getbbox()
	offset_x,offset_y,n_w,n_h = bb
	c_im = im.crop(bb)
	c_im.load()
	#c_im.show()
	out = {}
	out["name"] = path
	out["width"] = w
	out["height"] = h
	out["size_x"] = n_w
	out["size_y"] = n_h
	out["x"] = offset_x
	out["y"] = offset_y

	return c_im,out

class MapNode(object):
	def __init__(p_size, p_pos):
		self.pos = p_pos
		self.width, self.height = p_size
		self.h = h
		self.left = None
		self.right = None
		self.size_left = None
		self.size_right = None
		self.left_full = False
		self.right_full = False

	def geSize():
		return self.width, self.height

class MapTree(object):
	def __init__(p_size):
		self.width, self.height = p_size
		self.start = MapNode(p_size)

	def insertImage(p_size, node=None):
		if not node: node = self.start

		if not node.left_full:
			node.left_full = True
			new_node = MapNode(p_size)
			new_node.left_full = True
			new_node.left = p_size
			if (node.width-p_size[0]<node.height-p_size[1]):
				free_space = MapNode((node.width-p_size[0])


			free_node = MapNode()



		img_width, img_height = p_size


if __name__=="__main__":
	print "ok"